package com.smartleanx.module.hrm.controller.admin.companysystem;

import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.framework.common.pojo.PageResult;
import com.smartleanx.framework.security.core.annotations.PreAuthenticated;
import com.smartleanx.module.hrm.controller.admin.companysystem.vo.*;
import com.smartleanx.module.hrm.service.companysystem.CompanySystemService;
import com.smartleanx.module.infra.api.file.dto.FileRefRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static com.smartleanx.framework.common.pojo.CommonResult.success;

@Tag(name = "员工PC端 - 公司制度库")
@RestController
@RequestMapping("/hrm/pc-company-system")
@Validated
public class PCCompanySystemController {

    @Resource
    private CompanySystemService companySystemService;

    @GetMapping("/get")
    @Operation(summary = "获得公司制度库")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthenticated
    public CommonResult<CompanySystemRespVO> getCompanySystem(@RequestParam("id") Long id) {
        return success( companySystemService.getCompanySystem(id));
    }

    @GetMapping("/getFileRefList")
    @Operation(summary = "获取文件预览地址（列表）")
    @PreAuthenticated
    public CommonResult<List<CompanySystemFileRespVo>> getPreviewFileRef(@RequestParam("id") Long id){
        return success(companySystemService.getPreviewFileRef(id));
    }
    @GetMapping("/getEmployeeLearnPage")
    @Operation(summary = "员工端获取制度学习分页列表")
    @PreAuthenticated
    public CommonResult<PageResult<EmployeeLearnPageRespVo>> getEmployeeLearnPage(@Valid CompanySystemPageReqVO pageReqVO){
        return success(companySystemService.getEmployeeLearnPage(pageReqVO));

    }



}
